package com.xiamao.jdt.common;

import lombok.Data;

@Data
public class Result<T> {
    private int status;
    private String msg;
    private T data;
    
    public Result() {
    }
    
    public Result(int status, String msg, T data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }
    
    public static <T> Result<T> success(T data) {
        return new Result<>(200, "成功", data);
    }
    
    public static <T> Result<T> success(String msg, T data) {
        return new Result<>(200, msg, data);
    }
    
    public static <T> Result<T> error(int status, String msg) {
        return new Result<>(status, msg, null);
    }
    
    public static <T> Result<T> error(String msg) {
        return new Result<>(500, msg, null);
    }
}